<?php

use yii\db\Migration;

/**
 * Class m190920_060213_comment
 */
class m190920_060213_comment extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="评论表"';
        $this->createTable('{{%comment}}', [
            'id' => $this->primaryKey(),
            'comment' => $this->string()->notNull()->comment('评论内容'),
            'posts_id' => $this->integer()->comment('帖子id'),
            'member_id' => $this->integer()->notNull()->comment('评论者id'),
            'member_name' => $this->integer()->comment('评论者'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('状态 1待审核2拒绝3通过'),
            'error' => $this->string()->comment('拒绝理由'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%comment}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190920_060213_comment cannot be reverted.\n";

        return false;
    }
    */
}
